#!/bin/bash

CMD_SED="/bin/sed"
CMD_DATE="/bin/date"
CMD_ECHO="/bin/echo"
CMD_AWK="/usr/bin/awk"
CMD_LOG="/usr/bin/logger"
CMD_BC="/usr/bin/bc"

VARNISHSTATS="/usr/bin/varnishstat"
TIMESTAMP=$(${CMD_DATE} +%s)

# Printing Client requests received
VARNISH_REQ="`${VARNISHSTATS} -f client_req -1 |${CMD_AWK} '{print $2}'`"
VARNISH_HIT="`${VARNISHSTATS} -f cache_hit -1 |${CMD_AWK} '{print $2}'`"
VARNISH_MIS="`${VARNISHSTATS} -f cache_miss -1 |${CMD_AWK} '{print $2}'`"
VARNISH_SMA_NBY="`${VARNISHSTATS} -f sma_nbytes -1 |${CMD_AWK} '{print $2}'`"

#${CMD_ECHO} "${HOSTNAME} UOLGRAPH AGENTE_LASTRUN ${TIMESTAMP} varnish_requests ${VARNISH_REQ} varnish_hits ${VARNISH_HIT} varnish_misses ${VARNISH_MIS} varnish_smanbytes ${VARNISH_SMA_NBY}" | ${CMD_LOG} -p local5.info -t UOL007
${CMD_ECHO} "UOLGRAPH varnishstats 1 ${HOSTNAME} AGENTE_LASTRUN ${TIMESTAMP} varnish_requests ${VARNISH_REQ} varnish_hits ${VARNISH_HIT} varnish_misses ${VARNISH_MIS} varnish_smanbytes ${VARNISH_SMA_NBY}" | ${CMD_LOG} -p local5.info -t UOL007
